# This file is part of The Vu Toolkit.
#
# The Vu Toolkit is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
#
# The Vu Toolkit is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with The Vu Toolkit; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.
#
# Copyright © Zak Fenton 2008
#

module Cairo
	# .. i forgot the gradient base class name, this can be changed
	class LinearPattern
		# Adds a Vu::RGB stop at point
		def add_stop(p, c)
			add_color_stop_rgba(p, c.r, c.g, c.b, c.a)
		end
	end

	class Context
		# Sets the source to a Vu colour
		def set_source_colour (s)
			set_source_rgba(s.r,s.g,s.b,s.a)
		end
		
		def set_source_color (s)
			set_source_colour s
		end
		
		# Draw a rounded rectangle
		def rounded_rectangle (x,y,w,h,r)
			if r > w/2
				r = w/2
			end
			if r > h/2
				r = h/2
			end
			
			x2 = x+w
			y2 = y+h
			move_to(x+r,y)
			line_to(x2-r,y)
			curve_to(x2,y, x2,y, x2,y+r)
			line_to(x2,y2-r)
			curve_to(x2,y2, x2,y2, x2-r,y2)
			line_to(x+r,y2)
			curve_to(x,y2, x,y2, x,y2-r)
			line_to(x,y+r)
			curve_to(x,y, x,y, x+r,y)
			close_path
		end
	end
end
